package com.mobilebsc.datatype;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;


public class Perspective 
{
	private int id;
	private String name;
	private String description;
	private ArrayList<StrategicGoal> strategicGoals;
	
	/**
	 * Constructor for empty perspectives 
	 */
	public Perspective() {
		this.id = -1;
		this.name = "null";
		this.description = "null";
		this.strategicGoals = new ArrayList<StrategicGoal>();
	}
	
	/**
	 * Use constructor to create perspective from JSONObject
	 * @param perspectiveJSON
	 * @throws JSONException
	 */
	public Perspective(JSONObject perspectiveJSON) throws JSONException {
		this.id = perspectiveJSON.getInt("id");
		this.name = perspectiveJSON.getString("name");
		this.description = perspectiveJSON.getString("description");	
		this.strategicGoals = new ArrayList<StrategicGoal>();
	}
	
	public Perspective(int id, String name, String description) 
	{
		super();
		this.id = id;
		this.name = name;
		this.description = description;
		this.strategicGoals = new ArrayList<StrategicGoal>();
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public ArrayList<StrategicGoal> getStrategicGoals()
    {
        return strategicGoals;
    }
    public void setStrategicGoals(ArrayList<StrategicGoal> strategicGoals)
    {
        this.strategicGoals = strategicGoals;
    }
    
	/**
	 * Returns perspective as a JSONObject
	 * 
	 * @return
	 * @throws JSONException
	 */
	public JSONObject getJSON() throws JSONException {
		JSONObject json = new JSONObject();

		json.put("id", getId());
		json.put("name", getName());
		json.put("description", getDescription());

		return json;
	}
}